(function($, doc) {
	$.init({});		
	var userinfo = app.getState() || {};
    var uid = userinfo.user_id;
   
    refresh_data();
	$.plusReady(function() {
		doc.getElementById('manager_wechat').addEventListener('tap', function() {
			  //打开微信页
			  mui.openWindow({
			    id:'wechat.html',
			    url:'wechat.html',
			    show: {
					autoShow: false
				},
				waiting: {
					autoShow: true,
					title: '正在加载...'
				}
			  });
		}, false);
		
		doc.getElementById('manager_alipay').addEventListener('tap', function() {
			  //打开支付宝页
			  mui.openWindow({
			    id:'zhifubao.html',
			    url:'zhifubao.html',
			    show: {
					autoShow: false
				},
				waiting: {
					autoShow: true,
					title: '正在加载...'
				}
			  });
		}, false);
		
		doc.getElementById('manager_bank').addEventListener('tap', function() {
			  //打开银行列表页
			  mui.openWindow({
			    id:'card_list.html',
			    url:'card_list.html',
			    show: {
					autoShow: false
				},
				waiting: {
					autoShow: true,
					title: '正在加载...'
				}
			  });
		}, false);
		
		window.addEventListener('refresh_data',function(event){
		     refresh_data();
		});

	});
	
	function refresh_data(){
		mui.getJSON(apiurl + "User/bank_list/", {'user_id':uid,'_token':userinfo.token}, function(res) {
	        	console.log(JSON.stringify(res));
	        	if(res.status ==-3){
					plus.nativeUI.toast(res.msg);
					app.out();
					return false;
				}
	        	if(res.status==0){
					plus.nativeUI.toast(res.msg);
					return false;
				}
	        	var data=res.data;
	        	if(data.have_bank==1){
	        		doc.getElementById('bank_has_set').innerHTML='设置';
	        	}
	        	else{
	        		doc.getElementById('bank_has_set').innerHTML='未设置';
	        	}
	        	if(data.def_bank==1){
	        		doc.getElementById('bank_def').style.display='block';
	        	}
	        	else{
	        		doc.getElementById('bank_def').style.display='none';
	        	}
	        	
	        	if(data.have_alipay==1){
	        		doc.getElementById('alipay_has_set').innerHTML='设置';
	        	}
	        	else{
	        		doc.getElementById('alipay_has_set').innerHTML='未设置';
	        	}
	        	if(data.def_alipay==1){
	        		doc.getElementById('alipay_def').style.display='block';
	        	}
	        	else{
	        		doc.getElementById('alipay_def').style.display='none';
	        	}
	        	
	        	if(data.have_weixin==1){
	        		doc.getElementById('weixin_has_set').innerHTML='设置';
	        	}
	        	else{
	        		doc.getElementById('weixin_has_set').innerHTML='未设置';
	        	}
	        	if(data.def_weixin==1){
	        		doc.getElementById('weixin_def').style.display='block';
	        	}
	        	else{
	        		doc.getElementById('weixin_def').style.display='none';
	        	}
	        	
	        });
	}
}(mui, document));